#include "comm.hpp"
#include "log.hpp"

int main(){
    int shmid = getShm();
    // comlog(Debug, "getMemory success");

    char* shmaddr = (char*)shmat(shmid, nullptr, 0);
    // comlog(Debug, "shmat success");

    int fd = open(FILEPATH, O_WRONLY);
    if(fd < 0){
        comlog(Fatal, "open error,error string: %s, error code: %d", strerror(errno), errno);
        exit(1);
    }
    while(1){
        cout << "say out:" << endl;
        fgets(shmaddr, 4096, stdin);

        write(fd, "c", 1);
    }

    shmdt(shmaddr);
    comlog(Debug, "shmdt success");
    close(fd);
    return 0;
}